package com.exam.Entity;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

public class CustomUserDetails implements UserDetails {
    private String username;
    private String name;
    private String tname;
    private String sname;
    private int id;
    private int tno;
    private int sno;

    private String type;
    private String password;
    private List<GrantedAuthority> authorities;
    public void setTno(int tno) {
        this.tno = tno;
    }
    public int getTno() {
        return tno;
    }
    public void setSno(int sno) {
        this.sno = sno;
    }
    public int getSno() {
        return sno;
    }

    public void setName(String name) {
        this.name = name;
    }
    public String getName() {
        return name;
    }
    public void setId (int id) {
        this.id = id;
    }
    public int getId() {
        return id;
    }
    public void setSname(String sname) {
        this.sname = sname;
    }
    public String getSname() {
        return sname;
    }

    public void setTname(String tname) {
        this.tname = tname;
    }
    public String getTname() {
        return tname;
    }

    // 必须包含无参构造函数
    public CustomUserDetails() {}

    // 省略 getter 和 setter

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

    public String getUserType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }

}
